/*
 * saveconfig.h
 *
 *  Created on: 2021年10月9日
 *      Author: soliber
 */

#ifndef SAVECONFIG_H_
#define SAVECONFIG_H_

#include "main.h"
#include "crc.h"
#include "stdbool.h"

typedef struct{
	float pres_a;
	float pres_b;
	float volt_a;
	float volt_b;
	uint16_t tx_ant_dly;
	uint16_t rx_ant_dly;
}cali_t;

typedef struct{
	uint8_t device_id;
	uint8_t device_type;
	cali_t cali;
	uint32_t crc;
}config_t;

#define CFG_ADDR (0x08000000 + 1024*63)	//flash page 63 base address
extern const config_t const *pconfig;

bool config_is_valid(void);
int8_t config_cali(cali_t *cali);
int8_t config_device(config_t *cfg);

#endif /* SAVECONFIG_H_ */
